import Pageable from "@/utils/Pageable";
import { Request } from "@/utils/http";
import { ServerResponse } from "@/utils/serverResponse";

interface addParams {
    id?: string,
    username: string,
    phone: string,
    planName: string,
    planType: string,
    startTime: string,
    endTime: string,
    achieveStatus: number,
    createTime: string
}

interface queryParams {

}

interface listItem {

}

interface listVo extends Pageable {
    data: listItem[]
}

export default class DayPlanApi {

    // 获取计划列表
    public async planList(params: queryParams): Promise<listVo | undefined> {
        const res: ServerResponse<listVo> = await Request.post('/api/plan/dayPlan/list', params)
        return res.data
    }

    // 添加日计划
    public async addDayPlan(params: addParams): Promise<any> {
        const res: ServerResponse<number> = await Request.post('/api/plan/dayPlan/add', params)
        return res.data
    }

    //编辑日计划
    public async editDayPlan(params: addParams): Promise<any> {
        const res: ServerResponse<number> = await Request.post('/api/plan/dayPlan/edit', params)
        return res.data
    }

    // 删除计划
    public async deletePlan(id: string): Promise<any> {
        const res: ServerResponse<number> = await Request.get('/api/plan/dayPlan/delete?id=' + id)
        return res.data
    }

    // 导出
    public async exportData(): Promise<any> {
        const res = await Request.get('/api/plan/dayPlan/export', {
            responseType: 'blob'
        })
        return res
    }
}